/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: fzykd
 * Date: 2023-05-04
 * Time: 10:43
 */

public class Main {
    public static void main(String[] args)
    {
        LoadBalancer balancer, balancer2, balancer3;
        balancer = LoadBalancer.GetLoadBalancer();
        balancer2 = LoadBalancer.GetLoadBalancer();
        balancer3 = LoadBalancer.GetLoadBalancer();
        // 判断负载均衡器是否相同
        if (balancer == balancer2 && balancer == balancer3 && balancer2 == balancer3)
        {
            System.out.println("服务器负载均衡器是唯一的！");
        }
        // 增加服务器
        balancer.AddServer(new CustomService("Server 1") );
        balancer.AddServer(new CustomService("Server 2"));
        balancer.AddServer(new CustomService("Server 3"));
        balancer.AddServer(new CustomService("Server 4"));
        // 模拟客户端请求的分发
        for (int i = 0; i < 10; i++)
        {
            CustomService server = balancer.GetServer();
            System.out.println("该请求已分配至 : " + server.Name);
        }
    }
}
